/**
 * Created by Thyiad on 2018/5/9.
 */
let chartConfig = {
  getConfig(name, legend, time, data, colors){
    return {
      color: colors,
      title: {
        show: false,
        text: name,
        left: 10,
        textStyle: {
          color: 'white',
          fontSize: 20,
          fontWeight: 'bold'
        },
      },
      tooltip : {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      legend: {
        right: 10,
        textStyle: {
          color: '#dfdfdf',
          textOutline:"none"
        },
        data: legend ? legend.map(name => ({
          name,
          icon: 'circle'
        })) : []
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis : [
        {
          type : 'category',
          boundaryGap : false,
          data : time,
          axisLabel: {
            color: '#ccc'
          },
          splitLine: {
            lineStyle: {
              show: true,
              color: '#2a303c'
            }
          }
        }
      ],
      yAxis : [
        {
          type : 'value',
          axisLabel: {
            color: '#ccc'
          },
          splitLine: {
            lineStyle: {
              show: true,
              color: '#2a303c'
            }
          }
        }
      ],
      series: data ? data.map((item, index) => ({
        name: legend[index],
        type:'line',
        areaStyle: {normal: {
          opacity: 0.2
        }},
        data: item
      })) : []
    };
  },
  getConfigHcharts(name, legend, time, data, colors){
      return {
        chart:{
          backgroundColor:'transparent',
        },
        credits: {
          enabled:false
        },
        title: {
          text: name
        },
        subtitle: {
          text: null
        },
        plotOptions:{
          series: {
            label: {
              enabled: false,
            },
          }
        },
        colors:colors,
        xAxis: {
          categories: time,
          labels:{
            style:{
              color: '#fff',
              fontSize:'10px',
              textOutline:"none"
            }
          }
        },
        yAxis: {
          // tickPixelInterval: 16,
          title: {
            text: null
          },
          labels:{
            style:{
              color: '#fff',
              textOutline:"none"
            }
          }
        },
        legend: {
          enabled: false,
        },
        series: data?data.map((item, index)=>{
          return {
            name: legend[index],
            data: item,
          }
        }):[]
      }
  }
}

export default chartConfig;
